from rest_framework import serializers

from user_app.models import FreeCourse

class FreeCourseSerializer(serializers.ModelSerializer):
    '''限免课程'''
    stage_name = serializers.CharField(source='stage.name')
    teacher_name = serializers.CharField(source='teacher.name')
    #时间格式化
    start_time = serializers.DateTimeField(format='%Y-%m-%d %H-%M-%S')
    end_time = serializers.DateTimeField(format='%Y-%m-%d %H-%M-%S')
    
    class Meta:
        model = FreeCourse
        fields = '__all__'